#ifndef XMLFACTORY_H_
#define XMLFACTORY_H_

#include <xml/dom/xmlengdomimplementation.h>
#include <xml/dom/xmlengdocument.h>
#include <xml/dom/xmlengelement.h>

#include <ndefrecord.h>

class RXmlFactory;

class MXmlSerializable {
public:
    virtual TDesC8 const & XmlElementName() = 0;
    virtual void SerializeToXmlL(RXmlFactory & aFactory, TXmlEngElement & aElement) = 0;
};

class RXmlFactory {
    
public:
    
    void OpenL();
    void Close();
    
    TInt ToBuffer(RBuf8 & aBuf) { return iDocument.SaveL(aBuf); }
    RXmlEngDocument DocumentCloneL() { return iDocument.CloneDocumentL(); }
    
    void AddDataL(MXmlSerializable & aObject);
    void AddDataL(MXmlSerializable & aObject, TXmlEngElement aParent);
    
private:
    RXmlEngDOMImplementation iDomImplementation;
    RXmlEngDocument iDocument;
    TXmlEngElement iDocElement;
};

#endif /* XMLFACTORY_H_ */
